\ProvidesPackage{fig_design}

\RequirePackage{tikz}

\RequirePackage{xcolor}
\definecolor{bg_gray}{RGB}{230, 230, 230}
\definecolor{c_blank}{RGB}{147, 254, 123}
\definecolor{c_comp}{RGB}{247, 130, 255}
\definecolor{t_month}{RGB}{245, 129, 129}
\definecolor{t_day}{RGB}{154, 176, 229}
\definecolor{t_weekday}{RGB}{251, 227, 119}

\RequirePackage{fig_problem}

\newcommand{\drawComponentName}{

    \begin{scope}[xshift=-8cm, yshift=2cm, scale=0.6, rotate=180, xscale=-1]
        \draw[fill=c_comp, ultra thick] (0, 0) -- (1, 0) -- (1, 3) -- (2, 3) -- (2, 4) -- (0, 4) -- (0, 0);
        \draw[dotted, thin] (0, 1) -- (1, 1);
        \draw[dotted, thin] (0, 2) -- (1, 2);
        \draw[dotted, thin] (0, 3) -- (1, 3);
        \draw[dotted, thin] (1, 3) -- (1, 4);
    \end{scope}
    \node at (-7.5, -0.8) {$L$};

    \begin{scope}[xshift=-6.3cm, yshift=0.8cm, scale=0.6, rotate=270]
        \draw[fill=c_comp, ultra thick] (0, 0) -- (2, 0) -- (2, 3) -- (0, 3) -- (0, 2) -- (1, 2) -- (1, 1) -- (0, 1) -- (0, 0);
        \draw[dotted, thin] (1, 0) -- (1, 1) -- (2, 1);
        \draw[dotted, thin] (2, 2) -- (1, 2) -- (1, 3);
    \end{scope}
    \node at (-5.4, -0.8) {$U$};

    \begin{scope}[xshift=-3.5cm, yshift=2.3cm, scale=0.6, rotate=-30, yscale=-1]
        \draw[fill=c_comp, ultra thick] (1, 0) -- (2, 0) -- (2, 4) -- (1, 4) -- (1, 2) -- (0, 2) -- (0, 1) -- (1, 1) -- (1, 0);
        \draw[dotted, thin] (1, 1) -- (2, 1);
        \draw[dotted, thin] (1, 2) -- (2, 2);
        \draw[dotted, thin] (1, 3) -- (2, 3);
        \draw[dotted, thin] (1, 1) -- (1, 2);
    \end{scope}
    \node at (-3.4, -0.8) {$Y$};

    \begin{scope}[xshift=-2cm, yshift=-0.4cm, scale=0.6]
        \draw[fill=c_comp, ultra thick] (0, 0) -- (1, 0) -- (1, 1) -- (2, 1) -- (2, 3) -- (0, 3) -- (0, 0);
        \draw[dotted, thin] (0, 1) -- (1, 1) -- (1, 3);
        \draw[dotted, thin] (0, 2) -- (2, 2);
    \end{scope}
    \node at (-1.4, -0.8) {$P$};

    \begin{scope}[xshift=0.5cm, yshift=2.6cm, scale=0.6, rotate=-135]
        \draw[fill=c_comp, ultra thick] (2, 1) -- (3, 1) -- (3, 4) -- (0, 4) -- (0, 3) -- (2, 3) -- (2, 1);
        \draw[dotted, thin] (2, 2) -- (3, 2);
        \draw[dotted, thin] (2, 3) -- (3, 3);
        \draw[dotted, thin] (1, 3) -- (1, 4);
        \draw[dotted, thin] (2, 3) -- (2, 4);
    \end{scope}
    \node at (0.9, -0.8) {$V$};

    \begin{scope}[xshift=4.5cm, yshift=-0.4cm, scale=0.6, xscale=-1]
        \draw[fill=c_comp, ultra thick] (0, 0) -- (2, 0) -- (2, 2) -- (3, 2) -- (3, 3) -- (1, 3) -- (1, 1) -- (0, 1) -- (0, 0);
        \draw[dotted, thin] (1, 0) -- (1, 1) -- (2, 1);
        \draw[dotted, thin] (1, 2) -- (2, 2) -- (2, 3);
    \end{scope}
    \node at (3.5, -0.8) {$Z$};

    \begin{scope}[xshift=6cm, yshift=-0.5cm, scale=0.6, rotate=-15, xscale=-1]
        \draw[fill=c_comp, ultra thick] (1, 0) -- (2, 0) -- (2, 2) -- (1, 2) -- (1, 4) -- (0, 4) -- (0, 1) -- (1, 1) -- (1, 0);
        \draw[dotted, thin] (2, 1) -- (1, 1) -- (1, 2);
        \draw[dotted, thin] (0, 2) -- (1, 2);
        \draw[dotted, thin] (0, 3) -- (1, 3);
    \end{scope}
    \node at (5.5, -0.8) {$N$};

    \begin{scope}[xshift=7cm, yshift=-0.4cm, scale=0.6]
        \draw[fill=c_comp, ultra thick] (0, 0) -- (2, 0) -- (2, 3) -- (0, 3) -- (0, 0);
        \draw[dotted, thin] (0, 1) -- (2, 1);
        \draw[dotted, thin] (0, 2) -- (2, 2);
        \draw[dotted, thin] (1, 0) -- (1, 3);
    \end{scope}
    \node at (7.6, -0.8) {$O$};

}

\newcommand{\drawCellDiffExampleLeft}{

    % \fill[c_comp, draw=none] (0, 0) rectangle (4, 2);
    % \fill[c_comp, draw=none] (0, 2) rectangle (2, 3);
    \fill[lime, draw=none] (0, 3) rectangle (1, 2);
    \fill[lime, draw=none] (1, 2) rectangle (2, 1);
    \fill[lime, draw=none] (0, 0) rectangle (1, 1);
    \fill[lime, draw=none] (2, 0) rectangle (3, 1);
    \fill[lime, draw=none] (3, 1) rectangle (4, 2);

    \draw[ultra thick] (0, 0) -- (4, 0) -- (4, 2) -- (2, 2) -- (2, 3) -- (0, 3) -- (0, 0);
    \draw[ultra thick] (2, 0) -- (2, 1) -- (1, 1) -- (1, 2) -- (2, 2);

    \draw[dotted, thin] (1, 0) -- (1, 3);
    \draw[dotted, thin] (2, 0) -- (2, 2);
    \draw[dotted, thin] (3, 0) -- (3, 2);
    \draw[dotted, thin] (0, 1) -- (4, 1);
    \draw[dotted, thin] (0, 2) -- (4, 2);

}

\newcommand{\drawCellDiffExampleRight}{

    \pgfmathsetmacro \h {cos(30)}
    \pgfmathsetmacro \hdouble {cos(30) * 2}

    \fill[lime, draw=none] (0, 0) -- (2, 0) -- (1, \hdouble) -- (0, 0);
    \fill[white, draw=none] (1, 0) -- (0.5, \h) -- (1.5, \h) -- (1, 0);
    \fill[lime, draw=none] (1.5, \h) -- (2, \hdouble) -- (2.5, \h) -- (1.5, \h);
    
    \draw[ultra thick] (0, 0) -- (2, 0) -- (1, \hdouble) -- (0, 0);
    \draw[dotted, thin] (1, 0) -- (0.5, \h) -- (1.5, \h);
    
    \draw[ultra thick] (1, \hdouble) -- (3, \hdouble) -- (2.5, \h) -- (1.5, \h) -- (1, \hdouble);
    \draw[dotted, thin] (1.5, \h) -- (2, \hdouble) -- (2.5, \h);

}

\newcommand{\drawMinCompLeft}{

    % The surrounding box
    \draw[thick, rounded corners=10pt, fill=bg_gray] (-0.4, -0.4) rectangle (4.4, 6.4);

    \draw (0, 6) -- (4, 6) -- (4, 0);
    \draw (2, 6) -- (2, 5) -- (4, 5);
    \draw (3, 6) -- (3, 4) -- (4, 4);

    \node at (2.5, 5.5) {Jan};
    \node at (3.5, 5.5) {1};
    \node at (3.5, 4.5) {2};

}

\newcommand{\drawMinCompRight}{

    \draw (-1.6, -2) -- (-1.6, 4.8);

    \begin{scope}[xshift=1.3cm, yshift=1cm]

        \pgfmathsetmacro \scale {2}
        \pgfmathsetmacro \halfScale {\scale / 2}
        \pgfmathsetmacro \t {\scale * cos(30)}
        
        \draw (0, 0) -- (0, \scale) -- (\t, \halfScale) -- (0, 0);
        \draw (0, 0) -- (0, \scale) -- (-\t, \halfScale) -- (0, 0);
        \draw[fill=t_month] (0, 0) -- (\t, \halfScale) -- (\t, -\halfScale) -- (0, 0);
        \draw[fill=t_day] (0, 0) -- (-\t, \halfScale) -- (-\t, -\halfScale) -- (0, 0);
        
        \pgfmathsetmacro \y {1.5 * \scale}
        \draw[fill=t_weekday] (0, \scale) -- (-\t, \halfScale) -- (-\t, \y) -- (0, \scale);

        % \pgfmathsetmacro \R {0.1}
        % \draw[fill=black] (0, 0) circle (\R cm);
        % \draw[fill=black] (0, \scale) circle (\R cm);
        % \draw[fill=black] (\t, \halfScale) circle (\R cm);
        % \draw[fill=black] (-\t, \halfScale) circle (\R cm);
        % \draw[fill=black] (-\t, -\halfScale) circle (\R cm);
        % \draw[fill=black] (\t, -\halfScale) circle (\R cm);
        % \draw[fill=black] (-\t, \y) circle (\R cm);

        \pgfmathsetmacro \vA {\t * 0.45}
        \pgfmathsetmacro \vB {\t * 0.6}
        \node[scale = 1.3] at (\vA, \halfScale) {2};
        \node[scale = 1.3] at (-\vA, \halfScale) {1};
        \node[scale = 1.3] at (\vB, 0) {3};
        \node[scale = 1.3] at (-\vB, 0) {Jan};
        \node[scale = 1.3] at (-\vB, \scale) {Mon};

    \end{scope}
        
    \begin{scope}[xshift=5cm, yshift=3cm, rotate=210]
        \pgfmathsetmacro \t {cos(30)}
        \draw[ultra thick, fill=c_comp] (0, 0) -- (0, 1) -- (\t, 0.5) -- (0, 0);
    \end{scope}
    \node[scale = 1.5] at (6, 2.6) {$\times 2$};

    \begin{scope}[xshift=5.3cm, yshift=0.3cm, rotate=40]
        \pgfmathsetmacro \t {cos(30)}
        \draw[fill=c_comp] (0, 0) -- (0, 1) -- (\t, 0.5) -- (0, 0);
        \draw[fill=c_comp] (0, 0) -- (0, 1) -- (-\t, 0.5) -- (0, 0);
        \draw[ultra thick] (0, 0) -- (-\t, 0.5) -- (0, 1) -- (\t, 0.5) -- (0, 0);
    \end{scope}
    \node[scale = 1.5] at (6, 0.6) {$\times 1$};

}
